package com.jk.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jk.dao.RecordInvesDao;
import com.jk.entity.RecordInvesEntity;
import com.jk.pojo.UserBean;
import com.jk.utils.ReturnMsgUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author 位佳生
 * @title: RecordInvesService
 * @projectName springboot_financial
 * @description: TODO
 * @date 2022/11/911:41
 */
@Service
public class RecordInvesService {
    @Autowired
    private RecordInvesDao recordInvesDao;
    @Autowired
    private RedisTemplate redisTemplate;


    public List<RecordInvesEntity> getRecordInvesList(RecordInvesEntity recordInvesEntity) {
        UserBean userBean = (UserBean) redisTemplate.opsForValue().get("denglu");
        return recordInvesDao.getRecordInvesList(recordInvesEntity,userBean.getUser_id());
    }

    public List<RecordInvesEntity> getRecordInvesByIdList(Integer propertyId) {
        return recordInvesDao.getRecordInvesByIdList(propertyId);
    }

    public Map findRecordList() {
        try {
            QueryWrapper<RecordInvesEntity> wrapper = new QueryWrapper<>();
            List<RecordInvesEntity> list = recordInvesDao.selectList(wrapper);
            return ReturnMsgUtils.returnMsg(000,"成功查询到"+list.size()+"条",list);
        }catch (Exception e){
            e.printStackTrace();
            return ReturnMsgUtils.returnMsg(500,"服务器异常",null);
        }
    }
}
